package com.caesar.IoStream;

import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * @author caesar
 * @date 2025/7/14
 * @Description:
 * @apiNote
 */
public class exer5 {
    @Test
    public void test02() throws FileNotFoundException {
        Scanner input = new Scanner(new File("words.txt"));
        while(input.hasNextLine()){
            System.out.println(input.nextLine());
        }
        input.close();
    }


    @Test
    public void test01() throws FileNotFoundException{
        Scanner input = new Scanner(System.in);
        PrintStream ps = new PrintStream("words.txt");
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入第" + (i+1) + "句要对柴老师说的话：");
            String content = input.nextLine();
            ps.println(content);
        }
        input.close();
        ps.close();
    }
}
